export const DateFun = ({ timestamp, type }) => {
  const date = new Date(timestamp);

  // 年
  const year = date.getFullYear();

  // 月
  const month =
    date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1;

  // 日
  const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();

  // 时
  const hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();

  // 分
  const minutes =
    date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();

  // 秒
  const seconds =
    date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
